package com.ahncnk.powermonitor.admin.auth.service;

import com.ahncnk.powermonitor.admin.users.domain.UserPrincipal;

/**
 * UserContext
 *
 * @author lipei
 */
public class UserContext {
    private static ThreadLocal<UserPrincipal> userPrincipals = new ThreadLocal<>();

    public static void setCurrent(UserPrincipal userPrincipal) {
        userPrincipals.set(userPrincipal);
    }

    public static void removeCurrent() {
        userPrincipals.remove();
    }

    public static UserPrincipal current() {
        return userPrincipals.get();
    }
}
